package define.Demo_04;

import java.util.Scanner;

public class 字符串拼接和反转 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个int数组");
        String input = scanner.nextLine();
        int [] a = new int[input.length()];
        for (int i = 0; i < input.length(); i++) {
            a[i] = input.charAt(i)-'0';
        }
        System.out.println(concat(a));
    }
    public static String concat(int[] a) {
        if (a == null) {
            return "";
        }
        if (a.length == 0) {
            return "[]";
        }
        String ye = "[";
        for (int i = 0; i < a.length; i++) {
            if (i == a.length - 1) {
                ye = ye + a[i] + "]";
            }else {
            ye = ye  + a[i] + ", ";
            }
        }
        return ye;
    }
    public static String reverse(String str) {
        if (str == null) {
            return "";
        }
        if (str.length() == 0) {
            return "[]";
        }

        for (int i = str.length(); i > 0; i--) {
            char c = str.charAt(i);
            System.out.println(c);
        }
        return "";
    }
}
